import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);

// vuex 持久化
// vuex记录的变量不能刷新页面，一但刷新页面，数据就会重置丢失
const storge = localStorage;

export default new Vuex.Store({
  state: {
    token: storge.getItem("token"),
  },
  getters: {},
  mutations: {
    setToken(state, nv) {
      state.token = nv;
      storge.setItem("token", nv);
    },
  },
  actions: {},
  modules: {},
});
